package com.liwenfeng.bigevent.mapper;

import com.github.pagehelper.Page;
import com.liwenfeng.bigevent.pojo.Article;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Insert("insert into article( title, content, cover_img, state, category_id, create_user, create_time, update_time) values (#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},now(),now())")
    void add(Article article);

    Page<Article> list(Integer userId, String categoryId, String state);

    @Update("update article set title=#{title},content=#{content},cover_img=#{coverImg},state=#{state},category_id=#{categoryId},update_time=now() where id=#{id}")
    void update(Article article);

    @Select("select * from article where id=#{id}")
    Article getById(Integer id);

    @Delete("delete from article where id=#{id}")
    void delete(Integer id);
}
